<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>完成轮播图</title>
    <style>
        *{
            text-align: center;
        }
        img{
            width: 400px;
            border: 5px solid rebeccapurple;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <img src="images2/01.jpg" alt="">
</body>
</html>
<script>
    /*
        轮播图
    */
    var imgs = document.getElementsByTagName("img")[0];
    var imgArr = ["01.jpg","02.jpg","03.jpg","04.jpg","05.jpg"];
    var count=0;
    setInterval(function(){
        
        if(count>=imgArr.length){
            count = 0;
        }
        imgs.src = "images2/"+imgArr[count]; 
        count++;
    },2000)
</script>